<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>WebSocket</title>
</head>

<body>
  <p id="output"></p>

<script>
//Test http endpoint.
fetch('/about')
  .then(function(response) {
    return response.json();
  })
  .then(function(myJson) {
    console.log(myJson);
  });

// Test websocket endpoint.
const loc = window.location;
const uri = `ws://localhost:8080/ws`;
ws = new WebSocket(uri);
ws.onopen = function() {
  console.log('Connected');
};

ws.onmessage = function(evt) {
  var out = document.getElementById('output');
  out.innerHTML += evt.data + '<br>';
};

setInterval(function() {
  ws.send('Hello, Server!');
}, 1000);
</script>
</body>

</html>
